package com.ddwl.schema.bo.order;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * @author Fu Zhaohui
 * @date 2017/2/5
 */
@ApiModel("订单商品")
@Setter
@Getter
public class OrderItemBo {

    @ApiModelProperty("订单ID")
    private String orderId;
    @ApiModelProperty("商品ID")
    private String itemId;
    @ApiModelProperty("商品名称")
    private String itemName;
    @ApiModelProperty("商品描述")
    private String itemDesc;
    @ApiModelProperty("数量")
    private Integer itemQty;
    @ApiModelProperty("总金额")
    private BigDecimal amount;
    @ApiModelProperty("商品价格")
    private BigDecimal itemPrice;
    @ApiModelProperty("商品图片")
    private String itemImg;
    @ApiModelProperty("获得积分")
    private Integer score;

    public BigDecimal getAmount() {
        if (amount == null && itemPrice != null && itemQty != null) {
            return itemPrice.multiply(BigDecimal.valueOf(itemQty));
        } else {
            return amount;
        }
    }
}
